﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using OTS.BLL;

public partial class SysManage_SysMain_BLeft : INTPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["UserCode"] == null || Session["CoCode"] == null)
            {
                Response.Redirect("Welcome.aspx");
            }
            GetRight(Session["UserCode"].ToString(), Session["CoCode"].ToString());

            //测试：如果是Taylor则看到所有项
            if (Session["UserCode"].ToString().Equals("Taylor"))
            { ShowAll(); }
        }
    }
    //菜单控制
    protected void GetRight(string UserCode, string CoCode)
    {
        DataTable Dt = LeftMenuBLL.GetRightMenu(UserCode, CoCode);
        if (Dt.Rows.Count > 0)
        {
            int NBasic = 0;//基础设置
            int NServiceLogic = 0; // 业务信息设置
            int Ncontract = 0;// 合同维护
            int N4 = 0;// 装箱发货审批
            int NPrimary = 0;//个人信息
            int olpc = 0;

            #region 基础设置
            if (Dt.Select("WebType='BSysWebM'").Length > 0)
            {
                BSysWeb.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='BSysWebGroupM'").Length > 0)
            {
                BSysWebGroup.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='BSysWebAndGroupM'").Length > 0)
            {
                BSysWebAndGroup.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='BCompanyM'").Length > 0)
            {
                BCompany.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='BUserCoM'").Length > 0)
            {
                BUserCo.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='BUserM'").Length > 0)
            {
                BUser.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='BUserGroupM'").Length > 0)
            {
                BUserGroup.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='BUserAndGroupM'").Length > 0)
            {
                BUserAndGroup.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='webColumn'").Length > 0)
            {
                webColumn.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='webRolesGroup'").Length > 0)
            {
                webRolesGroup.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='webRolesGroupAndColumn'").Length > 0)
            {
                webRolesGroupAndColumn.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='ContractGroup'").Length > 0)
            {
                ContractGroup.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='ContractGroupAndRolesGroup'").Length > 0)
            {
                ContractGroupAndRolesGroup.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='CoDep'").Length > 0)
            {
                CoDep.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='ContractGroupAndCope'").Length > 0)
            {
                ContractGroupAndCope.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='dbLoginSet'").Length > 0)
            {
                dbLoginSet.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='ContractNoRegulation'").Length > 0)
            {
                ContractNoRegulation.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='ListName'").Length > 0)
            {
                ListName.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='SentEmailRecord'").Length > 0)
            {
                SentEmailRecord.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='UserCoGroup'").Length > 0)
            {
                UserCoGroup.Visible = true;
                ++NBasic;
            }
            if (Dt.Select("WebType='creditlimit'").Length > 0)
            {
                creditlimit.Visible = true;
                ++NBasic;
            }
            if (NBasic < 1)
            {
                TableBasis.Visible = false;
                div1.Visible = false;
            }
            #endregion
            #region 业务信息设置
            if (Dt.Select("WebType='BUserSysRightM'").Length > 0)
            {
                BUserSysRightM.Visible = true;
                ++NServiceLogic;
            }
            if (Dt.Select("WebType='setEmail'").Length > 0)
            {
                setEmail.Visible = true;
                ++NServiceLogic;
            }
            if (Dt.Select("WebType='webRolesAndUserRight'").Length > 0)
            {
                webRolesAndUserRight.Visible = true;
                ++NServiceLogic;
            }
            if (Dt.Select("WebType='AutoSentEmailSetting'").Length > 0)
            {
                AutoSentEmailSetting.Visible = true;
                ++NServiceLogic;
            }
            if (NServiceLogic < 1)
            {
                TableServiceLogic.Visible = false;
                div2.Visible = false;
            }
            #endregion
            #region 合同维护
            if (Dt.Select("WebType='contract'").Length > 0)
            {
                contract.Visible = true;
                ++Ncontract;
            }
            if (Dt.Select("WebType='PlantQuery'").Length > 0)
            {
                PlantQuery.Visible = true;
                ++Ncontract;
            }
            if (Ncontract < 1)
            {
                TableContract.Visible = false;
                div3.Visible = false;
            }

            #endregion
            #region 装箱/发货/审批
            if (Dt.Select("WebType='Incasement'").Length > 0)
            {
                Incasement.Visible = true;
                ++N4;
            }
            if (Dt.Select("WebType='DeliveryApply'").Length > 0)
            {
                DeliveryApply.Visible = true;
                ++N4;
            }
            if (Dt.Select("WebType='DeliveryApproval'").Length > 0)
            {
                DeliveryApproval.Visible = true;
                ++N4;
            }
            if (Dt.Select("WebType='Invoice'").Length > 0)
            {
                Invoice.Visible = true;
                ++N4;
            }
            if (Dt.Select("WebType='DeliveryAllList'").Length > 0)
            {
                DeliveryAllList.Visible = true;
                ++N4;
            }
            if (Dt.Select("WebType='InvoiceList'").Length > 0)
            {
                InvoiceList.Visible = true;
                ++N4;
            }
            if (Dt.Select("WebType='IncasementList'").Length > 0)
            {
                IncasementList.Visible = true;
                ++N4;
            }
            if (N4 < 1)
            {
                Table4.Visible = false;
                div4.Visible = false;
            }
            #endregion

            #region On Line Payment Collection

            if (Dt.Select("WebType='mcinformationm'").Length > 0)
            {
                mcinformationm.Visible = true;
                ++olpc;
            }
            if (Dt.Select("WebType='mctoorder'").Length > 0)
            {
                mctoorder.Visible = true;
                ++olpc;
            }
            if (Dt.Select("WebType='mcapproval'").Length > 0)
            {
                mcapproval.Visible = true;
                ++olpc;
            }
            if (Dt.Select("WebType='mctoorderapproval'").Length > 0)
            {
                mctoorderapproval.Visible = true;
                ++olpc;
            }
            if (Dt.Select("WebType='mcnegative'").Length > 0)
            {
                mcnegative.Visible = true;
                ++olpc;
            }
            if (Dt.Select("WebType='mctodelivery'").Length > 0)
            {
                mctodelivery.Visible = true;
                ++olpc;
            }
            if (Dt.Select("WebType='mctodeliveryapproval'").Length > 0)
            {
                mctodeliveryapproval.Visible = true;
                ++olpc;
            }
            if (Dt.Select("WebType='mctoinvoice'").Length > 0)
            {
                mctoinvoice.Visible = true;
                ++olpc;
            }
            if (Dt.Select("WebType='mctxtexport'").Length > 0)
            {
                mctxtexport.Visible = true;
                ++olpc;
            }
            if (Dt.Select("WebType='mcactionrecord'").Length > 0)
            {
                mcactionrecord.Visible = true;
                ++olpc;
            }
            if (olpc < 1)
            {
                TBOLPC.Visible = false;
                div6.Visible = false;
            }
            #endregion

            #region 个人信息
            if (Dt.Select("WebType='SPwdUpdate'").Length > 0)
            {
                SPwdUpdate.Visible = true;
                ++NPrimary;
            }
            if (Dt.Select("WebType='userDefineShowColumn'").Length > 0)
            {
                userDefineShowColumn.Visible = true;
                ++NPrimary;
            }
            if (NPrimary < 1)
            {
                TablePrimary.Visible = false;
                div5.Visible = false;
            }
            #endregion
        }
    }
    //测试：显示所有项
    protected void ShowAll()
    {
        #region
        BSysWeb.Visible = true;
        BSysWebGroup.Visible = true;
        BSysWebAndGroup.Visible = true;
        BCompany.Visible = true;
        BUser.Visible = true;
        BUserCo.Visible = true;
        BUserGroup.Visible = true;
        BUserAndGroup.Visible = true;
        BUserSysRightM.Visible = true;
        ContractNoRegulation.Visible = true;
        ListName.Visible = true;
        SentEmailRecord.Visible = true;
        UserCoGroup.Visible = true;
        creditlimit.Visible = true;

        webColumn.Visible = true;
        //webRoles.Visible = true;
        webRolesAndUserRight.Visible = true;
        webRolesGroup.Visible = true;
        webRolesGroupAndColumn.Visible = true;
        dbLoginSet.Visible = true;
        setEmail.Visible = true;
        contract.Visible = true;
        AutoSentEmailTest.Visible = true;
        AutoSentEmailSetting.Visible = true;

        DeliveryApply.Visible = true;
        Incasement.Visible = true;
        DeliveryAllList.Visible = true;
        DeliveryApproval.Visible = true;
        Invoice.Visible = true;
        InvoiceList.Visible = true;
        IncasementList.Visible = true;
        PlantQuery.Visible = true;

        SPwdUpdate.Visible = true;
        // SBacklog.Visible = true;
        userDefineShowColumn.Visible = true;

        ContractGroup.Visible = true;
        ContractGroupAndRolesGroup.Visible = true;
        //PaymentType.Visible = true;
        //AECEName.Visible = true;
        //ProductTypeModel.Visible = true;
        CoDep.Visible = true;
        ContractGroupAndCope.Visible = true;


        TBOLPC.Visible = true;
        div6.Visible = true;

        mcinformationm.Visible = true;
        mctoorder.Visible = true;
        //mcapproval.Visible = true;
        mctoorderapproval.Visible = false;
        mcnegative.Visible = false;
        //mctodelivery.Visible = true;
        mctodeliveryapproval.Visible = false;
        mctoinvoice.Visible = true;
        mctxtexport.Visible = true;
        mcactionrecord.Visible = true;

        #endregion
    }
    
}